package com.ftg.learn.day05.giteelogin.dao;

import com.ftg.learn.day05.giteelogin.entity.UserEntity;

/**
 * 用户数据处理类型
 *
 * 用户名不能为null , 6-8
 * 密码不能为null , 6-8
 *
 * @author 布衣
 */
public class UserDao {

    private UserEntity[] users;

    private int size;


    /**
     * 注册
     * @param u1 用户信息
     */
    public void register(UserEntity u1){

        if(null == users){
            users = new UserEntity[10];
        }

        resize();
        users[size++] = u1;
    }

    /**
     * 扩容
     */
    private void resize(){
        if(size == users.length){
            UserEntity[] newUsers = new UserEntity[users.length+(users.length >> 1)];
            System.arraycopy(users,0,newUsers,0,size);
            users = newUsers;
        }
    }


}
